#ifndef __QpwContentManager__
#define __QpwContentManager__

#include <QtGui/QWidget>
#include <QpwAccountManager.h>
#include <QpwGeometryDatabase.h>
#include <QpwStyleDatabase.h>
#include <QpwSubTypeDatabase.h>
#include "ui_QpwContentManagerWindow.h"

class QpwGeometryEdit;

class QpwContentManager : public QWidget, public Ui::QpwContentManagerWindow {
    Q_OBJECT
public:
    explicit QpwContentManager( QWidget * parent = 0 );
    ~QpwContentManager();

    QString dataDirPath() const { return p_dataDirPath; }

public slots:
    void setDataDirPath( const QString & dataDirPath );
    void updateContent();
    void clearContent();

private slots:
    void on_addButton_clicked();
    void on_removeButton_clicked();
    void on_clearButton_clicked();
    void on_saveButton_clicked();
    void on_cancelButton_clicked();
    void on_tabWidget_currentChanged( int currentIndex );
    void on_styleView_itemActivated( QTreeWidgetItem * item, int column );
    void on_subTypeView_itemActivated( QTreeWidgetItem * item, int column );
    void on_accountView_itemActivated( QTreeWidgetItem * item, int column );
    void on_geometryView_itemActivated( QTreeWidgetItem * item, int column );
    void on_geoEditApplyButton_clicked();
    void on_geoEditRemoveAllButton_clicked();

private:
    enum Tabs {
        StyleEditTab = 0,
        SybTypeEditTab = 1,
        AccountManagerTab = 2,
        GeometryTab = 3,
    };

    void add( const QpwStyle & style );
    void add( const QpwSubType & subType );
    void add( const QpwAccount & account );
    void add( const QpwWorld::Geometry & geometry );
    void updateContent( Tabs tab );
    void update( QTreeWidgetItem * item, const QpwStyle & style );
    void update( QTreeWidgetItem * item, const QpwSubType & subType );
    void update( QTreeWidgetItem * item, const QpwAccount & account );
    void update( QTreeWidgetItem * item, const QpwWorld::Geometry & geometry );
    QString styleName( const QUuid & uuid ) const;
    QString geometryName( const QUuid & uuid ) const;
    QString eventProcessorName( quint32 id ) const;
    QString destroyProcessorName( quint32 id ) const;
    QpwStyle editStyle( const QpwStyle & style = QpwStyle() ) const;
    QpwSubType editSubType( const QpwSubType & subType = QpwSubType() ) const;
    QpwAccount editAccount( const QpwAccount & account = QpwAccount() ) const;
    QpwWorld::Geometry editGeometry( const QpwWorld::Geometry & geometry = QpwWorld::Geometry() ) const;

    QString p_dataDirPath;
    Tabs currentTab;
    QpwStyleDatabase styleDatabase;
    QpwSubTypeDatabase subTypeDatabase;
    QpwAccountManager accountManager;
    QpwGeometryEdit * geometryEditor;
    QpwGeometryDatabase geometryDatabase;

};

#endif//__QpwContentManager__
